#include "common.h"

int maxProfit(int* prices, int pricesLen)
{
	int maxFit = 0, prev = INT_MAX;
	for (int day = 0; day < pricesLen; day++)
		if (prices[day] < prev)
			prev = prices[day];
		else {
			maxFit += prices[day] - prev;
			prev = prices[day];
		}
	return maxFit;
}
